package com.tanhua.model.vo;

import com.tanhua.model.domain.BasePojo;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.mongo.RecommendUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/1 12:49
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TodayBestVo extends BasePojo {

    private Long id; //用户id
    private String avatar;
    private String nickname;
    private String gender; //性别 man woman
    private Integer age;
    private String[] tags;
    private Long fateValue; //缘分值

    /**
     * 在vo对象中补充一个工具方法，封装转化过程
     */

    public static TodayBestVo init(UserInfo userInfo, RecommendUser recommendUser){

        TodayBestVo vo = new TodayBestVo();
        // 将userInfo中的属性拷贝到TodayBest
        BeanUtils.copyProperties(userInfo, vo);

        // 单身,本科,年龄相仿  切割开存入到vo的tags数组里面
        if(userInfo.getTags() != null){
            vo.setTags(userInfo.getTags().split(","));
        }
        // 将魅力值设置到vo中
        vo.setFateValue(recommendUser.getScore().longValue());
        return vo;
    }
}
